package com.zj.config;

import com.zj.pojo.Apple;
import com.zj.pojo.Fruit;
import com.zj.tool.SpringUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.util.StringUtils;

//@Configuration
//@EnableApple
public class BeanFactoryTest2 implements BeanFactoryPostProcessor {
    @Autowired
    SpringUtil util;

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        Apple bean1 = beanFactory.getBean(Apple.class);
        Fruit bean11 = beanFactory.getBean(Fruit.class);
        String configure1 = util.getBeanName("Configure1");
        if (!StringUtils.isEmpty(configure1)) {
            Object bean2 = util.getBean(configure1);
        }
        String configInner1 = util.getBeanName("ConfigInnerAdapter1");
        if (!StringUtils.isEmpty(configInner1)) {
            Object bean3 = util.getBean(configInner1);
        }
        String configInner2 = util.getBeanName("ConfigInner2");
        if (!StringUtils.isEmpty(configInner2)) {
            Object bean4 = util.getBean(configInner2);
            System.out.println("aa");

            return;

        }
    }
}
